package com.hjm.system.controller.question;


import com.hjm.common.core.domain.Result;
import com.hjm.common.core.domain.page.TableDataInfo;
import com.hjm.common.core.controller.BaseController;
import com.hjm.system.domain.question.dto.QuestionAddDTO;
import com.hjm.system.domain.question.dto.QuestionEditDTO;
import com.hjm.system.domain.question.dto.QuestionQueryDTO;
import com.hjm.system.domain.question.vo.QuestionDetailVO;
import com.hjm.system.service.question.impl.QuestionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Autowired
    QuestionServiceImpl questionService;

    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){

        return getTableData(questionService.list(questionQueryDTO));
    }


    @PostMapping("/add")
    public Result<Void> add(@RequestBody QuestionAddDTO questionAddDTO){

        return toResult(questionService.add(questionAddDTO));
    }



    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail( Long questionId){
        return Result.ok(questionService.detail(questionId));
    }


    @PutMapping("/edit")
    public Result<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toResult(questionService.edit(questionEditDTO));
    }


    @DeleteMapping("/delete")
    public Result<Void> delete(Long questionId){
        return toResult(questionService.delete(questionId));
    }
}
